package hotel.quartz.oversea.service.impl;

import hotel.quartz.oversea.entity.form.JobForm;
import hotel.quartz.oversea.service.FpJobService;
import hotel.quartz.oversea.service.JobAndTriggerService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author HuangT
 * @Date 2020/11/20 15:04
 */
@Slf4j
@Service("fpJobService")
public class FpJobServiceImpl implements FpJobService {

    @Resource
    private JobAndTriggerService jobAndTriggerService;

    /**
     * <H1>暂停定时器</H1>
     *
     * @author HuangT
     * @Date 2020/11/18 20:47
     */
    @Override
    public void endingJob(String jobClassName, String timestamp) {
        JobForm jobForm = new JobForm();
        jobForm.setJobClassName(jobClassName);
        jobForm.setJobGroupName("Fp");
        try {
            jobAndTriggerService.pauseJob(jobForm);
            log.warn( jobClassName + "执行暂停job: {},{}", timestamp, jobForm);
        } catch (SchedulerException e) {
            log.error(jobClassName + "{} 执行暂停job异常: {}", timestamp, jobForm);
            log.error(e.getMessage(), e);
        }
    }
}
